<template>
    <h1>注册页面</h1>

    <table>
        <tr>
            <td>手机号:</td>
            <td>
                <input type="text" v-model="Phone" >
            </td>
        </tr>

        <tr>
            <td>密码:</td>
            <td>
                <input type="password" v-model="Password" >
            </td>
        </tr>

        <tr>
            <td>确认密码:</td>
            <td>
                <input type="password" v-model="ConfirmPassword" >
            </td>
        </tr>

        <tr>
            <td colspan="2">
                <input type="button" value="注册" @click="Region" >
            </td>
        </tr>

    </table>


</template>

<script setup lang="ts">
import {ref} from 'vue'
import {useRouter} from 'vue-router'

const router = useRouter();


const Phone = ref('');
const Password = ref('');
const ConfirmPassword = ref('');

const Region = ()=>{

    if(Phone.value==''){
        alert('手机号不能为空!');
        return;
    }

    if(Password.value==''){
        alert('密码不能为空!');
        return;
    }

    if(ConfirmPassword.value==''){
        alert('确认密码不能为空!');
        return;
    }

    if(Phone.value.length>11 || Phone.value.length<11   ){
        alert('手机号的长度只能是11位');
        return;
    }

    if(Password.value!=ConfirmPassword.value){
        alert('密码和确认密码不一致!');
        return;
    }

    if(Phone.value=='13512349876' && Password.value=='123456' ){
        alert('用户注册成功!');
        router.push({
            name:'RegionCg',
            params:{
                Phone:Phone.value
            }
        })
    }
    else{
        alert('注册的手机号或者密码错误!');
        return;
    }

}

</script>
